package com.silence.qhyh.webpro.mvp.ui.activity.mine;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.allen.library.SuperTextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.silence.qhyh.webpro.R;
import com.silence.qhyh.webpro.mvp.model.entity.VipImgBean;
import com.silence.qhyh.webpro.mvp.ui.adapter.VipUpdateAdapter;
import com.vondear.rxtool.RxActivityTool;
import com.vondear.rxui.view.RxTitle;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author silence
 * 店主升级
 */
public class VipUpdateActivity extends BaseActivity {

    @BindView(R.id.rx_title)
    RxTitle rxTitle;
    @BindView(R.id.sb_submit_order)
    SuperTextView sbSubmitOrder;
    @BindView(R.id.rv_vip)
    RecyclerView mRecyclerView;

    private static final int[] VipImg = {R.mipmap.icon_vip1, R.mipmap.icon_vip2, R.mipmap.icon_vip3, R.mipmap.icon_vip4, R.mipmap.icon_vip5, R.mipmap.icon_vip6};
    private ArrayList<VipImgBean> mDataList;


    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {

    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_vip_update;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        rxTitle.setLeftFinish(this);
        initView();
        initData();
        initAdapter();
    }

    @OnClick({R.id.sb_submit_order})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.sb_submit_order:
                RxActivityTool.skipActivity(this, PaySuccessActivity.class);
                break;
            default:
                break;
        }
    }

    private void initView() {
        mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    }

    private void initAdapter() {
        BaseQuickAdapter vipUpdateAdapter = new VipUpdateAdapter(R.layout.item_updatevip, mDataList);
        vipUpdateAdapter.openLoadAnimation();
        vipUpdateAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

            }
        });
        mRecyclerView.setAdapter(vipUpdateAdapter);
    }

    private void initData() {
        mDataList = new ArrayList<>();
        for (int i = 0; i < VipImg.length; i++) {
            VipImgBean item = new VipImgBean();
            item.setImageResource(VipImg[i]);
            mDataList.add(item);
        }
    }

}
